import { toast, to, err } from './wxapi';
module.exports = async (path, data) => {
  try {
    const res = await wx.cloud.callContainer({
      config: {
        env: 'prod-0gg6hnwgf8f69aeb',
      },
      path,
      method: 'post',
      header: {
        'X-WX-SERVICE': 'prod-ymk-order',
      },
      data,
    });
    if (data.scope === 'mop' && res.data.respCode === 410) {
      toast(res.data.msg);
      setTimeout(() => {
        to('/pages/store/store');
      }, 1000);
    }
    return res.data;
  } catch (error) {
    err(error);
    throw error;
  }
};
